package cn.fengshenghospital.controller;

import cn.fengshenghospital.entity.Section;
import cn.fengshenghospital.service.SectionService;
import cn.fengshenghospital.vo.JsonBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/section")
public class SectionController {
    @Autowired
    private SectionService sectionService;
    @GetMapping("/queryAllSection")
    public JsonBean queryAllSection(){
        JsonBean jsonBean=new JsonBean("queryAllSection");
        try {
            List<Section> list= sectionService.queryAllSection();
            jsonBean.setData(list);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/querySectionByParentId")
    public JsonBean querySectionByParentId(int parentId){
        JsonBean jsonBean=new JsonBean("querySectionByParentId");
        try {
            List<Section> list= sectionService.querySectionByParentId(parentId);
            jsonBean.setData(list);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
    @GetMapping("/querySectionInfoBySid")
    public JsonBean querySectionInfoBySid(int id){
        JsonBean jsonBean=new JsonBean("querySectionInfoBySid");
        try {
            Section section=sectionService.querySectionInfoBySid(id);
            jsonBean.setData(section);
            jsonBean.setStatus(200);
        }catch (Exception e){
            jsonBean.setStatus(-1);
        }
        return jsonBean;
    }
}
